home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / coding / 80x86 / code32.lzh / EXAMPLE3.ASM < prev    next >
Assembly Source File  |  1993-01-09  |  2KB  |  60 lines

  1.  
  2. ; This program prints the square root of a number you put on the command line.
  3. ;
  4. ; Link this one with ARGC32, and enable CCHEKSTR.
  5.  
  6.         .386p
  7.         jumps
  8. code32  segment para public use32
  9.         assume cs:code32, ds:code32, ss:code32
  10.  
  11. include start32.inc
  12. include argc32.inc
  13.  
  14. public  _main
  15.  
  16. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  17. ; DATA
  18. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  19. syntaxmsg       db      'SYNTAX: EXAMPLE3 <hex number to root>$'
  20. numbuf          db      32 dup(0)
  21.  
  22. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  23. ; CODE
  24. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  25.  
  26. include sqrt.rt
  27. include pdosstr.rt
  28. include putnumtm.rt
  29. include strltu.rt
  30. include strhtn.rt
  31.  
  32. ;-----------------------------------------------------------------------------
  33. exiterr:
  34.         mov edx,offset syntaxmsg
  35.         call _putdosmsg
  36.         jmp _exit
  37.  
  38. ;═════════════════════════════════════════════════════════════════════════════
  39. _main:
  40.         xor al,al                       ; get number string from command line
  41.         mov edx,offset numbuf
  42.         call _cchekstr
  43.         jc exiterr
  44.  
  45.         call _strltu                    ; lower to uppercase cuz strhtn needz
  46.         call _strhtn                    ; it that way
  47.  
  48.         call _sqrt
  49.  
  50.         mov cl,7
  51.         call _putnumtomem
  52.         call _putdosstr                 ; buffer was all zeros before, so its
  53.                                         ; already zero-terminated
  54.         jmp _exit
  55.  
  56.  
  57. code32  ends
  58.         end
  59.  
  60.